﻿CREATE PROCEDURE [dbo].[proc_RefeicoesUpdate]
(
	@IdRefeicaoContratada bigint,
	@DataRefeicao date,
	@TotalVendasPrevisto decimal(18,5) = NULL,
	@TotalCustosPrevisto decimal(18,5) = NULL,
	@TotalVendasEfectivo decimal(18,5) = NULL,
	@TotalCustosEfectivo decimal(18,5) = NULL,
	@RacioMPrimasPrevisto decimal(18,5) = NULL,
	@RacioMPrimasEfectivo decimal(18,5) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Refeicoes]
	SET
		[TotalVendasPrevisto] = @TotalVendasPrevisto,
		[TotalCustosPrevisto] = @TotalCustosPrevisto,
		[TotalVendasEfectivo] = @TotalVendasEfectivo,
		[TotalCustosEfectivo] = @TotalCustosEfectivo,
		[RacioMPrimasPrevisto] = @RacioMPrimasPrevisto,
		[RacioMPrimasEfectivo] = @RacioMPrimasEfectivo,
		[DataAlteracao] = GETDATE()
	WHERE
		[IdRefeicaoContratada] = @IdRefeicaoContratada
	AND	[DataRefeicao] = @DataRefeicao


	SET @Err = @@Error


	RETURN @Err
END
